﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Texfina.BOQry.Co;
using System.Collections;
using Texfina.Core.Common;

namespace wfCompras
{
    public partial class wfOrdenCompraBnd : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                btnNuevo.ImageUrl = Constants.ConstMenuControlValue.BUTTON_NEW;
                LlenarGrid();
              
               
            }
        }

        private void LlenarGrid()
        {
            try
            {
                //periodo llenar con sesion
                
                gvList.DataSource=BOrdenCompra.OrderCompra_qry03("2013",txtIdOrdenCompra.Text, txtProducto.Text);
          
                gvList.DataBind();
            }
            catch (Exception ex)
            {
                Response.Write(ex.ToString());
            }
            
        }

        protected void btnBuscar_Click(object sender, EventArgs e)
        {
            LlenarGrid();
        }

        protected void gvList_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            switch (e.CommandName)
            {
                case "Detalle":
                   string Id_ordenco = (string)e.CommandArgument;
                    Hashtable htDatos = new Hashtable();
                    htDatos.Add("Id_ordenco", Id_ordenco);
                    htDatos.Add("in_ventana", "1");
                    Session["htaOcompra"] = htDatos;
                    Response.Redirect("wfOrdenCompra.aspx");
                break;
                case "cmdadd":
                    string id_oc = (string)e.CommandArgument;
                    Hashtable htDatos1 = new Hashtable();
                    htDatos1.Add("Id_ordenco", id_oc);
                    htDatos1.Add("in_ventana", "1");
                    Session["htaOC"] = htDatos1;
                    Response.Redirect("WfOrdenCompraFactura.aspx");
                break;
            }
        }

  

        protected void btnNuevo_Click(object sender, ImageClickEventArgs e)
        {
            Session["htaOcompra"] = null;
            Hashtable HtaDatos = new Hashtable();
            Session["htaOcompraNuevo"] = HtaDatos;
            Response.Redirect("wfOrdenCompra.aspx");
        }

    }
}